<template>
  <ElForm inline>
    <ElFormItem label="贷款种类">
      <ElInput v-model="queryCondition.materialCodeLike"></ElInput>
    </ElFormItem>
    <ElFormItem>
      <ElButton icon="Search" type="primary" @click="queryByCondition(1)"></ElButton>
    </ElFormItem>
  </ElForm>

  <ElTable :border="true" stripe :data="pageInfo.results">
    <ElTableColumn prop="loanCode" label="贷款编号"></ElTableColumn>
    <ElTableColumn prop="materialCode" label="贷款种类"></ElTableColumn>
    <ElTableColumn prop="loanApplier" label="申请公司"></ElTableColumn>
    <ElTableColumn prop="billState" label="贷款状态"></ElTableColumn>
    <ElTableColumn prop="applyAmount" label="贷款金额"></ElTableColumn>
    <ElTableColumn prop="bizCard" label="对公银行卡"></ElTableColumn>
    <ElTableColumn prop="bizLicense" label="营业执照"></ElTableColumn>
    <ElTableColumn>
      <template #default="{ row }">
        <ElButton type="primary" size="small" @click="open4Audit(row)">二审</ElButton>
        <ElButton type="warning" size="small">重交</ElButton>
      </template>
    </ElTableColumn>
  </ElTable>
  <ElPagination
    background
    layout="prev, pager, next"
    :total="pageInfo.total"
    :page-size="queryCondition.pageSize"
    :current-page="queryCondition.pageNum"
    @current-change="queryByCondition"
  />
  <LoanSecondAudit ref="secondAuditDrawer" @post-audit="queryByCondition"></LoanSecondAudit>
</template>
<script lang="ts" setup>
const secondAuditDrawer: any = ref(null)
const pageInfo = reactive({
  total: 0,
  results: [] as Array<any>
})
const queryCondition = reactive({
  pageNum: 1,
  pageSize: 6,
  loanApplier: '',
  firstAuditor: '',
  bankName: '',
  materialCodeLike: ''
})
const queryByCondition = async (pageNum?: number) => {
  if (pageNum) {
    queryCondition.pageNum = pageNum
  }
  const res = await axios({
    method: 'post',
    url: 'http://localhost:9091/loanBill/queryForBank',
    data: queryCondition
  })
  pageInfo.total = res.data.total
  pageInfo.results = res.data.records
}
const open4Audit = (row: any) => {
  secondAuditDrawer.value.show(row)
}
onMounted(() => {
  queryByCondition(1)
})
</script>
<style lang="scss" scoped></style>
